﻿@using GoodMan.Infrastructure.Entities.Entity;
@{
    ViewBag.Title = "团购商品列表";
    Layout = "~/Areas/WorkSpace/Views/Shared/_CollegeAdminTemplete.cshtml";
    ItemListBox<Product> data = ViewBag.Data;
    //List<ProductCategory> categoryList = ViewBag.CategorysList;
    int CategoryID = ViewBag.CategoryID;
    int SubCategoryID = ViewBag.subcategoryId;
    string SearchKey = ViewBag.SearchKey;
}
@section head{
 <script type="text/javascript" src="/Scripts/jquery.js"></script>
    <script type="text/javascript" src="/Scripts/plug.js"></script>
     <link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
    <script type="text/javascript">
        var control = new plug.Control();
        var datasource = @Html.Raw(ViewBag.CategorysList);
        $(function () {
               control.BuildRelationSelect({element:'ProductType',defaultvalue:@CategoryID}, {element:'ProductSubType',defaultvalue:@SubCategoryID}, datasource);
            
        });
    </script>
}
<div id="content-header">
    <h1>
        团购商品</h1>
</div>
<div id="breadcrumb">
    <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>
        首页</a> <a href="#" class="tip-bottom">商品管理</a> <a href="#" class="current">团购商品</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <h5>
                        团购商品列表</h5>
                </div>
                <div class="widget-content nopadding">
                <form action="/CollegeAdmin/SearchGroupBuyProducts" method="post" class="form-horizontal">
                <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td style="width:40%">
                                <div class="control-group">
                                    <label class="control-label">
                                        商品分类</label>
                                    <div class="controls">
                                        <select id="ProductType" name="ProductType" style="width:150px">
                                        </select>
                                        <select id="ProductSubType" name="ProductSubType" style="width:150px">
                                        </select>
                                    </div>
                                </div>
                            </td>
                            <td style="width:40%">
                                <div class="control-group">
                                    <label class="control-label">
                                        商品关键字</label>
                                    <div class="controls">
                                        <input type="text" value="@SearchKey" name="ProductKey" style="width: 80%" />
                                    </div>
                                </div>
                            </td>
                            <td style="width:20%">
                                <div class="controls" style="margin-left: 30px;">
                                    <button type="submit" class="btn btn-primary">
                                        <i class="icon-search icon-white"></i>查询</button>
                                </div>
                            </td>
                        </tr>
                        <tr>
                        <td colspan="3">
                    <table class="table table-bordered table-striped">
                        <thead>
                            <tr > 
                                <th width="10%">
                                    货号
                                </th>
                                <th width="20%">
                                    名称
                                </th>
                                <th width="8%">
                                    购入价格
                                </th>
                                <th width="8%">
                                    原始售价
                                </th>
                                <th width="8%">
                                    团购价格
                                </th>
                                 <th width="6%">
                                    库存
                                </th>
                                <th width="8%">
                                    人数上限
                                </th>
                                <th width="11%">
                                    开始时间
                                </th>
                                <th width="11%">
                                    结束时间
                                </th>
                                
                                <th width="10%">
                                    操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                        @{
                             if (data != null && data.Data != null && data.Data.Any())
                              {
                                    foreach (var item in data.Data)
                                    {
                                        <tr>
                                            <td  style="vertical-align:middle">
                                               @item.ProductCode
                                            </td>
                                            <td  style="vertical-align:middle">
                                               <a href="../../Shop/ProductItemView?Id=@item.Id" target="_blank" ><span title="@item.ProductName">@item.ProductName</span></a>
                                            </td>
                                            
                                            <td  style="vertical-align:middle">
                                                @item.PurchasePrice
                                            </td>
                                            <td  style="vertical-align:middle">
                                                @item.OriginalPrice
                                            </td>
                                            <td  style="vertical-align:middle">
                                                @item.DefaulSalePrice
                                            </td>
                                            
                                            <td  style="vertical-align:middle">
                                               <a href="/workspace/CollegeAdmin/ProductRepertoryDetail?id=@item.Id&areacode=2" title="点击进行库存设置">@item.TotalRemain</a> 
                                                <br /><a class="btn btn-primary btn-mini" href="/workspace/CollegeAdmin/ProductRepertoryDetail?id=@item.Id&areacode=2" title="点击进行库存设置">入库</a>
                                            </td>
                                
                                             <td  style="vertical-align:middle">
                                                @item.CapsPeople
                                            </td>
                                            <td  style="vertical-align:middle">
                                                <span title="@item.StartDate">@item.StartDate</span>
                                            </td>
                                            <td  style="vertical-align:middle">
                                                <span title="@item.EndDate">@item.EndDate</span>
                                            </td>
                                              
                                            <td class="center" style="vertical-align:middle"><a href="/workspace/CollegeAdmin/GroupBuyProductsDetail?id=@item.Id" class="btn btn-primary btn-mini" style="margin-top:10px">编辑</a> <a onclick='return confirm("确定要删除吗?")' href="/workspace/CollegeAdmin/DeleteGrouBuyProduct?id=@item.Id&page=@data.CurrentPage&productkey=@SearchKey&categoryId=@CategoryID&subcategoryId=@SubCategoryID" class="btn btn-danger btn-mini"  style="margin-top:10px">删除</a>
                                            </td>
                                        </tr>
                                    }
                              }
                             else
                             {
                                  <tr>
                                    <td colspan="10" align="center">
                                        无团购商品数据，请添加
                                    </td>
                                </tr>  
                             }
                        }
                            
                        </tbody>
                    </table>
                    </td>
                    </tr>
                    </table>
                </form>
                </div>
                @Html.Raw(data.PageItemSegment)
            </div>
        </div>
        @{
                if (ViewBag.isSuccess != null)
                {
                    if (ViewBag.isSuccess)
                    { 
                <div class="alert alert-success">
                    <strong>删除商品成功！</strong>
                </div>
                 
                    }
                    else
                    {
                 <div class="alert alert-error">
                    <strong>删除商品失败！</strong>
                </div>
                    }
                }
            }
    </div>
</div>
@section tail{
     <script type="text/javascript" src="/scripts/select2.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#likProduct').addClass('open');

            $('#likProduct').addClass('active');

            $('#ProductType').each(function () {
                $(this).select2();
            });

            $('#ProductSubType').each(function () {
                $(this).select2();
            });
        });
    </script>
}
